class Example{

    static void main(String[] args){
        String sample = "Hello world";
        println(sample[4]); // the 5th character
        println(sample[-1]); // the last character
        println(sample[1..2]); // the second to the third character
        println(sample[4..2]); // the 5th to the 3rd character
        
        int len = sample.length();
        println(sample[len-1..0]); // reverse the string

        String a = "Hello";
        println("Hello"*3); // 重复3次 Hello

        // 用空格填充 左->右
        println(a.center(30)); //             Hello

        println("$a compare ignore to hello:"+a.compareToIgnoreCase("hello")); // 0:=

        a.eachMatch("."){
            ch -> print("$ch.");
        }
        println();

        println("a.endsWith(o)" + a.endsWith("o"));

        def strs = 'a'..'z';
        println(strs);
        strs.each {
            ch -> print("$ch ");
        }
        println();
        println("strs from "+strs.getFrom()+" to "+ strs.getTo());
        def str2 = strs.reverse();
        println(str2);


    }
}